home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 10
/
010.d81
/
trial error
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
1KB
|
39 lines
10 rem ***************************
20 rem * -trial and error- *
30 rem * shlomo ginsberg *
35 rem * use for any expression *
40 rem * by changing lines *
45 rem * 150 and 190 *
50 rem ***************************
60 poke53280,11:poke53281,0
70 print"[147]";
80 print" trial and error ";
90 print" shlomo ginsberg, 1984 "
100 input" initial point ";x
110 input" initial step ";s
120 input" convergence criterion";c
130 rem
140 i%=0:k=1
150 y=x*x*x-6*x*x+11*x-6
160 print"[147]cycle=";i%;"x=";x;"y=";y
170 ifabs(y)<cthen280
180 x=x+s:goto260
190 y=x*x*x-6*x*x+11*x-6
200 print"cycle=";i%;"x="x;"y=";y
210 ifabs(y)<cthen280
220 j%=sgn(y1)*sgn(y)
230 ifj%<>1thenk=0.5
240 s=k*j%*s
250 x=x+s
260 y1=y:i%=i%+1
270 goto190
280 print" that's all folks "
290 rem stop
300 :
60000 print"do it again?"
60010 poke198,0:wait198,1:getk$:ifk$<>"y"andk$<>"n"thenpoke53280,rnd(1)*15:goto60010
60020 ifk$="y"thenrun
63000 rem connect back to loadstar
63010 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
63020 poke631,13:poke632,13:poke198,2:end